package com.molichuxing.services.infrastructure.dao;

import com.molichuxing.framework.dao.RootMapper;
import com.molichuxing.services.infrastructure.bean.OrderRenegeBean;
import com.molichuxing.services.infrastructure.dto.response.OrderNegotiateRenegeDto;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

public interface OrderRenegeMapper extends RootMapper<OrderRenegeBean> {

    /**
     * 查询退租信息
     *
     * @param orderCode    订单号
     * @param renegeStatus 退租状态
     * @return
     */
    OrderRenegeBean getRenege(@Param("orderCode") Long orderCode, @Param("renegeStatus") Integer renegeStatus);

    /**
     * 查询退租信息
     *
     * @param orderCode
     * @param renegeStatus
     * @return
     */
    OrderRenegeBean getRenegeByRenegeStatus(@Param("orderCode") Long orderCode,
                                            @Param("renegeStatusList") List<Integer> renegeStatus);

    /**
     * 订单退租状态修改
     *
     * @param orderCode       订单号
     * @param renegeStatus    退租状态
     * @param preRenegeStatus 取消前退租状态
     * @return
     */
    int modifyRenegeStatus(@Param("orderCode") Long orderCode, @Param("renegeStatus") Integer renegeStatus,
                           @Param("preRenegeStatus") Integer preRenegeStatus);

    /**
     * 订单退租费用修改
     *
     * @param orderRenegeBean
     * @return
     */
    int modifyCost(OrderRenegeBean orderRenegeBean);

    /**
     * 订单退租退租收款人信息修改
     *
     * @param orderRenegeBean
     * @return
     */
    int modifyPayee(OrderRenegeBean orderRenegeBean);

    List<OrderRenegeBean> getRenegeByRenegeTime(@Param("renegeTimeStart") LocalDateTime renegeTimeStart,
                                                @Param("renegeTimeEnd") LocalDateTime renegeTimeEnd,
                                                @Param("renegeStatusList") List<Integer> effectiveRenegeStatus);

    /**
     * 退租总数
     *
     * @param renegeType
     * @param renegeStatus
     * @return
     */
    long getRenegeTotal(@Param("renegeType") int renegeType);

    List<OrderNegotiateRenegeDto> getPaged(@Param("params") Map<String, Object> params,
                                           @Param("pageNum") int pageNum, @Param("pageSize") int pageSize);

    long getPagedCount(@Param("params") Map<String, Object> params);

    /**
     * @param orderCode
     * @param value
     * @param overdueDaysTotal
     * @param overdueNumTotal
     * @return
     */
    long modifyOverdue(@Param("orderCode") Long orderCode, @Param("renegeStatus") int renegeStatus,
                       @Param("overdueDaysTotal") Integer overdueDaysTotal, @Param("overdueNumTotal") Integer overdueNumTotal);
}